package com.boc.ewr.risk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boc.ewr.bcimp.entity.Pro;
import com.boc.ewr.bcimp.mapper.ProMapper;
import com.boc.ewr.risk.entity.ProYesterday;
import com.boc.ewr.risk.mapper.ProYesterdayMapper;
import com.boc.ewr.risk.service.IProRiskService;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author : Wzz
 * @create : 2023-05- 05- 16:59
 * @desc :
 */
@Service
public class ProRiskServiceImpl extends ServiceImpl<ProMapper, Pro> implements IProRiskService {


    @Autowired
    private ProMapper proMapper;

    @Autowired
    private ProYesterdayMapper proYesterdayMapper;

    @Autowired
    private ISysBaseAPI sysBaseAPI;

    /**
     * 新增、变更协议清单:
     * 获取PRO文件，比对前一日的，如有变动进行提示变动情况
     */
    @Override
    public List<Pro> changeRisk() {
        List<Pro> proList = proMapper.changeRisk();
        return proList;
    }


    /**
     * 同一客户号下不同对账渠道
     */
    @Override
    public List<Pro> sameCusmNoDifChannelRisk() {
        List<Pro> resultList = proMapper.sameCusmNoDifChannelRisk();

        return resultList;


       /* TODO: 2023/6/2  消息推送
        Set<String> signedOrgSet = new HashSet();
        StringBuilder resultStrBd = new StringBuilder();
        for (Pro pro : resultProList) {
            signedOrgSet.add(pro.getSignedOrg());
            resultStrBd.append("客户号").append(pro.getCusmNo()).append("\n");
        }

        Map<String, String> map = new HashMap<>();
        map.put("errorData", resultStrBd.toString());
        map.put("errorMsg", "同一客户号下存在不同对账渠道 可维护到同一协议下");
        map.put("fileName", "Pro");

        String ewrRiskWarningContent = sysBaseAPI.parseTemplateByCode(new TemplateDTO("ewr_risk_warning", map));

        // todo 获取 签约机构 后，获取该机构下所有成员，作为信息的接受者（暂行办法）
        String toUser = ToUserUtil.genToUser(signedOrgSet);

        MessageDTO messageDTO = new MessageDTO(
                "system",
                toUser,
                "风险预警提示",
                ewrRiskWarningContent);

        sysBaseAPI.sendSysAnnouncement(messageDTO);*/
    }

}
